package com.mhy.book.app;

import com.mhy.book.mapper.BookMapper;
import com.mhy.book.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanInitMain {
    public static void main(String[] args) {
        ApplicationContext ioc = new ClassPathXmlApplicationContext("bean_init.xml");
        BookMapper bookMapper = ioc.getBean("bookMapper",BookMapper.class);
        //System.out.println(bookMapper);
        bookMapper.selectById(1);
        System.out.println("----------------");

        BookService service = ioc.getBean("service", BookService.class);
        service.queryBook();

        System.out.println("----------------");

        BookMapper bookMapper2 = ioc.getBean("bookMapper2", BookMapper.class);
        bookMapper2.selectById(1);

        System.out.println("----------------");

        BookMapper bookMapper3 = ioc.getBean("bookMapper3", BookMapper.class);
        bookMapper3.selectById(1);
    }
}
